/*
 * Copyright 2018- The Pixie Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

syntax = "proto3";

package px.services;

option go_package = "artifacttrackerpb";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "src/shared/artifacts/versionspb/versions.proto";

// ArtifactTracker tracks versions of released artifacts.
service ArtifactTracker {
  // GetArtifactList is used to request a list of artifacts.
  rpc GetArtifactList(GetArtifactListRequest) returns (px.versions.ArtifactSet);
  // GetDownloadLink is used to request a signed URL.
  rpc GetDownloadLink(GetDownloadLinkRequest) returns (GetDownloadLinkResponse);
}

message GetArtifactListRequest {
  string artifact_name = 1;
  // Select the type of artifact to look for and filter by.
  px.versions.ArtifactType artifact_type = 2;
  // Limit the number of responses, ordered by time.
  int64 limit = 3;
}

// GetDownloadLinkRequest is used to get a signed URL for a specific artifact. Only singular
// artifacts are currently supported.
message GetDownloadLinkRequest {
  string artifact_name = 1;
  string version_str = 2;
  px.versions.ArtifactType artifact_type = 3;
}

// GetDownloadLinkResponse returns a signed url that can be used to download the artifact.
message GetDownloadLinkResponse {
  string url = 1;
  // The sha256 of the artifact.
  string sha256 = 2 [ (gogoproto.customname) = "SHA256" ];
  google.protobuf.Timestamp valid_until = 3;
}
